package com.peace.hospital.mapper.drugstorage;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.peace.hospital.entity.drugstorage.Outdrug;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xie
 * @since 2019-11-25
 */
@Mapper
public interface OutdrugMapper extends BaseMapper<Outdrug> {
//添加出库药品信息
    @Insert("insert into drugstorage.outdrug(outid,drugid,outdnum,outddate)\n"+
        "values(#{outid},#{drugid},#{outdnum},#{outddate})")
    public int addOutDrug(Outdrug outdrug);
// //    出库单id查询出库药品
    @Select("select drugid,outdnum,outddate from drugstorage.outdrug \n" +
            "where outid=#{outid}")
    @Results({
            @Result(column = "drugid",property = "drugid"),
            @Result(column = "drugid",property = "druginformation",one=@One(select="com.peace.hospital.mapper.publicn.DruginformationMapper.selectByDrugId",fetchType= FetchType.LAZY))
    })
    public List<Outdrug> findOutDByOutid(Outdrug outdrug);
}
